Welcome to class!

  1. Introductions
  2. Class overview
  3. Getting R up and running

Welcome!

[Photo by Belinda Fewings on Unsplash]

About Us

Alex Edwards (he/him)

Adjunct Instructor, Department of Biostatistics and Bioinformatics, RSPH

PhD candidate in Spatial Epidemiology, University of Lincoln, UK

Email:

What is R?

Bell Labs old logo

[source: http://www.r-project.org/, https://en.wikipedia.org/wiki/S_(programming_language), https://en.wikipedia.org/wiki/Bell_Labs)]

What is R?

R logo

[source: http://www.r-project.org/, https://en.wikipedia.org/wiki/R_(programming_language)]

Why R?

R-Ladies - a non-profit civil society community [source: https://rladies-baltimore.github.io/]

Why not R?

tortoise and hare

[source -School vector created by nizovatina - www.freepik.com]

Introductions

What do you hope to get out of the class?

Why do you want to use R?

image of rocks with word hope painted on [Photo by Nick Fewings on Unsplash]

Course Website

Our Google Classroom

Materials are uploaded for your perusal. We are constantly trying to improve content!

Intro to R course logo

Learning Objectives

Course Format

Setting up RStudio Cloud

RStudio is an integrated development environment (IDE) that makes it easier to work with R.

Basic terms

R jargon: https://link.springer.com/content/pdf/bbm%3A978-1-4419-1318-0%2F1.pdf

Package - a package in R is a bundle or “package” of code (and or possibly data) that can be loaded together for easy repeated use or for sharing with others.

Packages are sort of analogous to a software application like Microsoft Word on your computer. Your operating system allows you to use it, just like having R installed (and other required packages) allows you to use packages.

R hex stickers for packages

Basic terms

Function - a function is a particular piece of code that allows you to do something in R. You can write your own, use functions that come directly from installing R, or use functions from additional packages.

A function might help you add numbers together, create a plot, or organize your data. More on that soon!

sum(1, 20234)
[1] 20235

Basic terms

Argument - what you pass to a function

sum(1, 20234)
[1] 20235
round(0.627, digits = 2)
[1] 0.63
round(0.627, digits = 1)
[1] 0.6

Basic terms

Object - an object is something that can be worked with in R - can be lots of different things!

… many more

Variable and Sample

examples: temperature, length, count, color, category

examples: people, houses, viruses etc.

head(iris)
  Sepal.Length Sepal.Width Petal.Length Petal.Width Species
1          5.1         3.5          1.4         0.2  setosa
2          4.9         3.0          1.4         0.2  setosa
3          4.7         3.2          1.3         0.2  setosa
4          4.6         3.1          1.5         0.2  setosa
5          5.0         3.6          1.4         0.2  setosa
6          5.4         3.9          1.7         0.4  setosa

Columns and Rows

R hex stickers for packages [source]

Sample = Row
Variable = Column

Data objects that looks like this is often called a data frame.

Fancier versions from the tidyverse are called tibbles (more on that soon!).

More on Functions and Packages

Picture of R package stickers

Using Packages

Picture of Hadley Wickham (source: https://twitter.com/hadleywickham)

Tidyverse and Base R

We will mostly show you how to use tidyverse packages and functions.

This is a newer set of packages designed for data science that can make your code more intuitive as compared to the original older Base R.

Tidyverse advantages:
- consistent structure - making it easier to learn how to use different packages
- particularly good for wrangling (manipulating, cleaning, joining) data
- more flexible for visualizing data

Packages for the tidyverse are managed by a team of respected data scientists at RStudio.

Tidyverse hex sticker

See this article for more info.

Collection of R packages

We have an R package called jhur that will make sure all the packages are installed.

You can just copy and paste the below code into your console - we’ll explain what it all means in the next day or two

install.packages("remotes")
remotes::install_github("muschellij2/jhur")

Note it may take ~5-10 minutes to run.

Useful (+ mostly Free) Resources

Useful (+ mostly Free) Resources

Need help?

Summary

🏠 Class Website

Website tour!

🏠 Class Website